/**
 */
package de.thwildau.tm.moses.asn1.asn1.impl;

import de.thwildau.tm.moses.asn1.asn1.Asn1Package;
import de.thwildau.tm.moses.asn1.asn1.DefinedValue;
import de.thwildau.tm.moses.asn1.asn1.ExceptionIdentification;
import de.thwildau.tm.moses.asn1.asn1.Type;
import de.thwildau.tm.moses.asn1.asn1.Value;

import org.eclipse.emf.common.notify.Notification;
import org.eclipse.emf.common.notify.NotificationChain;

import org.eclipse.emf.ecore.EClass;
import org.eclipse.emf.ecore.InternalEObject;

import org.eclipse.emf.ecore.impl.ENotificationImpl;
import org.eclipse.emf.ecore.impl.MinimalEObjectImpl;

/**
 * <!-- begin-user-doc -->
 * An implementation of the model object '<em><b>Exception Identification</b></em>'.
 * <!-- end-user-doc -->
 * <p>
 * The following features are implemented:
 * <ul>
 *   <li>{@link de.thwildau.tm.moses.asn1.asn1.impl.ExceptionIdentificationImpl#getNumber <em>Number</em>}</li>
 *   <li>{@link de.thwildau.tm.moses.asn1.asn1.impl.ExceptionIdentificationImpl#getDefValue <em>Def Value</em>}</li>
 *   <li>{@link de.thwildau.tm.moses.asn1.asn1.impl.ExceptionIdentificationImpl#getType <em>Type</em>}</li>
 *   <li>{@link de.thwildau.tm.moses.asn1.asn1.impl.ExceptionIdentificationImpl#getValue <em>Value</em>}</li>
 * </ul>
 * </p>
 *
 * @generated
 */
public class ExceptionIdentificationImpl extends MinimalEObjectImpl.Container implements ExceptionIdentification
{
  /**
   * The default value of the '{@link #getNumber() <em>Number</em>}' attribute.
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @see #getNumber()
   * @generated
   * @ordered
   */
  protected static final long NUMBER_EDEFAULT = 0L;

  /**
   * The cached value of the '{@link #getNumber() <em>Number</em>}' attribute.
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @see #getNumber()
   * @generated
   * @ordered
   */
  protected long number = NUMBER_EDEFAULT;

  /**
   * The cached value of the '{@link #getDefValue() <em>Def Value</em>}' containment reference.
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @see #getDefValue()
   * @generated
   * @ordered
   */
  protected DefinedValue defValue;

  /**
   * The cached value of the '{@link #getType() <em>Type</em>}' containment reference.
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @see #getType()
   * @generated
   * @ordered
   */
  protected Type type;

  /**
   * The cached value of the '{@link #getValue() <em>Value</em>}' containment reference.
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @see #getValue()
   * @generated
   * @ordered
   */
  protected Value value;

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  protected ExceptionIdentificationImpl()
  {
    super();
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  @Override
  protected EClass eStaticClass()
  {
    return Asn1Package.Literals.EXCEPTION_IDENTIFICATION;
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  public long getNumber()
  {
    return number;
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  public void setNumber(long newNumber)
  {
    long oldNumber = number;
    number = newNumber;
    if (eNotificationRequired())
      eNotify(new ENotificationImpl(this, Notification.SET, Asn1Package.EXCEPTION_IDENTIFICATION__NUMBER, oldNumber, number));
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  public DefinedValue getDefValue()
  {
    return defValue;
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  public NotificationChain basicSetDefValue(DefinedValue newDefValue, NotificationChain msgs)
  {
    DefinedValue oldDefValue = defValue;
    defValue = newDefValue;
    if (eNotificationRequired())
    {
      ENotificationImpl notification = new ENotificationImpl(this, Notification.SET, Asn1Package.EXCEPTION_IDENTIFICATION__DEF_VALUE, oldDefValue, newDefValue);
      if (msgs == null) msgs = notification; else msgs.add(notification);
    }
    return msgs;
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  public void setDefValue(DefinedValue newDefValue)
  {
    if (newDefValue != defValue)
    {
      NotificationChain msgs = null;
      if (defValue != null)
        msgs = ((InternalEObject)defValue).eInverseRemove(this, EOPPOSITE_FEATURE_BASE - Asn1Package.EXCEPTION_IDENTIFICATION__DEF_VALUE, null, msgs);
      if (newDefValue != null)
        msgs = ((InternalEObject)newDefValue).eInverseAdd(this, EOPPOSITE_FEATURE_BASE - Asn1Package.EXCEPTION_IDENTIFICATION__DEF_VALUE, null, msgs);
      msgs = basicSetDefValue(newDefValue, msgs);
      if (msgs != null) msgs.dispatch();
    }
    else if (eNotificationRequired())
      eNotify(new ENotificationImpl(this, Notification.SET, Asn1Package.EXCEPTION_IDENTIFICATION__DEF_VALUE, newDefValue, newDefValue));
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  public Type getType()
  {
    return type;
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  public NotificationChain basicSetType(Type newType, NotificationChain msgs)
  {
    Type oldType = type;
    type = newType;
    if (eNotificationRequired())
    {
      ENotificationImpl notification = new ENotificationImpl(this, Notification.SET, Asn1Package.EXCEPTION_IDENTIFICATION__TYPE, oldType, newType);
      if (msgs == null) msgs = notification; else msgs.add(notification);
    }
    return msgs;
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  public void setType(Type newType)
  {
    if (newType != type)
    {
      NotificationChain msgs = null;
      if (type != null)
        msgs = ((InternalEObject)type).eInverseRemove(this, EOPPOSITE_FEATURE_BASE - Asn1Package.EXCEPTION_IDENTIFICATION__TYPE, null, msgs);
      if (newType != null)
        msgs = ((InternalEObject)newType).eInverseAdd(this, EOPPOSITE_FEATURE_BASE - Asn1Package.EXCEPTION_IDENTIFICATION__TYPE, null, msgs);
      msgs = basicSetType(newType, msgs);
      if (msgs != null) msgs.dispatch();
    }
    else if (eNotificationRequired())
      eNotify(new ENotificationImpl(this, Notification.SET, Asn1Package.EXCEPTION_IDENTIFICATION__TYPE, newType, newType));
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  public Value getValue()
  {
    return value;
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  public NotificationChain basicSetValue(Value newValue, NotificationChain msgs)
  {
    Value oldValue = value;
    value = newValue;
    if (eNotificationRequired())
    {
      ENotificationImpl notification = new ENotificationImpl(this, Notification.SET, Asn1Package.EXCEPTION_IDENTIFICATION__VALUE, oldValue, newValue);
      if (msgs == null) msgs = notification; else msgs.add(notification);
    }
    return msgs;
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  public void setValue(Value newValue)
  {
    if (newValue != value)
    {
      NotificationChain msgs = null;
      if (value != null)
        msgs = ((InternalEObject)value).eInverseRemove(this, EOPPOSITE_FEATURE_BASE - Asn1Package.EXCEPTION_IDENTIFICATION__VALUE, null, msgs);
      if (newValue != null)
        msgs = ((InternalEObject)newValue).eInverseAdd(this, EOPPOSITE_FEATURE_BASE - Asn1Package.EXCEPTION_IDENTIFICATION__VALUE, null, msgs);
      msgs = basicSetValue(newValue, msgs);
      if (msgs != null) msgs.dispatch();
    }
    else if (eNotificationRequired())
      eNotify(new ENotificationImpl(this, Notification.SET, Asn1Package.EXCEPTION_IDENTIFICATION__VALUE, newValue, newValue));
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  @Override
  public NotificationChain eInverseRemove(InternalEObject otherEnd, int featureID, NotificationChain msgs)
  {
    switch (featureID)
    {
      case Asn1Package.EXCEPTION_IDENTIFICATION__DEF_VALUE:
        return basicSetDefValue(null, msgs);
      case Asn1Package.EXCEPTION_IDENTIFICATION__TYPE:
        return basicSetType(null, msgs);
      case Asn1Package.EXCEPTION_IDENTIFICATION__VALUE:
        return basicSetValue(null, msgs);
    }
    return super.eInverseRemove(otherEnd, featureID, msgs);
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  @Override
  public Object eGet(int featureID, boolean resolve, boolean coreType)
  {
    switch (featureID)
    {
      case Asn1Package.EXCEPTION_IDENTIFICATION__NUMBER:
        return getNumber();
      case Asn1Package.EXCEPTION_IDENTIFICATION__DEF_VALUE:
        return getDefValue();
      case Asn1Package.EXCEPTION_IDENTIFICATION__TYPE:
        return getType();
      case Asn1Package.EXCEPTION_IDENTIFICATION__VALUE:
        return getValue();
    }
    return super.eGet(featureID, resolve, coreType);
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  @Override
  public void eSet(int featureID, Object newValue)
  {
    switch (featureID)
    {
      case Asn1Package.EXCEPTION_IDENTIFICATION__NUMBER:
        setNumber((Long)newValue);
        return;
      case Asn1Package.EXCEPTION_IDENTIFICATION__DEF_VALUE:
        setDefValue((DefinedValue)newValue);
        return;
      case Asn1Package.EXCEPTION_IDENTIFICATION__TYPE:
        setType((Type)newValue);
        return;
      case Asn1Package.EXCEPTION_IDENTIFICATION__VALUE:
        setValue((Value)newValue);
        return;
    }
    super.eSet(featureID, newValue);
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  @Override
  public void eUnset(int featureID)
  {
    switch (featureID)
    {
      case Asn1Package.EXCEPTION_IDENTIFICATION__NUMBER:
        setNumber(NUMBER_EDEFAULT);
        return;
      case Asn1Package.EXCEPTION_IDENTIFICATION__DEF_VALUE:
        setDefValue((DefinedValue)null);
        return;
      case Asn1Package.EXCEPTION_IDENTIFICATION__TYPE:
        setType((Type)null);
        return;
      case Asn1Package.EXCEPTION_IDENTIFICATION__VALUE:
        setValue((Value)null);
        return;
    }
    super.eUnset(featureID);
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  @Override
  public boolean eIsSet(int featureID)
  {
    switch (featureID)
    {
      case Asn1Package.EXCEPTION_IDENTIFICATION__NUMBER:
        return number != NUMBER_EDEFAULT;
      case Asn1Package.EXCEPTION_IDENTIFICATION__DEF_VALUE:
        return defValue != null;
      case Asn1Package.EXCEPTION_IDENTIFICATION__TYPE:
        return type != null;
      case Asn1Package.EXCEPTION_IDENTIFICATION__VALUE:
        return value != null;
    }
    return super.eIsSet(featureID);
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  @Override
  public String toString()
  {
    if (eIsProxy()) return super.toString();

    StringBuffer result = new StringBuffer(super.toString());
    result.append(" (number: ");
    result.append(number);
    result.append(')');
    return result.toString();
  }

} //ExceptionIdentificationImpl
